package com.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

/**
 * @Author: li wenda
 * @Description:
 * @Date Created in 2021-10-28 21:59
 * @Modified By:
 */
@RestController
public class LoginController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("loginInfo/{id}")
    public ResponseEntity info(@PathVariable(name = "id") Long id) {
        // 使用eureka中注册的服务名称
        String url = "http://eureka-client-provider/user/info/" + id;
        Map user = restTemplate.getForObject(url, Map.class);
        return ResponseEntity.ok(user);
    }
}
